{	Problem: http://codeforces.ru/problemset/problem/8/B
	Verdict: Accepted
}
var a:array[-110..110,-110..110] of boolean; s:string; i,x,y,k:longint; f:boolean;
begin
fillchar(a,sizeof(a),false);
readln(s);
a[0][0]:=true;
f:=true;
x:=0;
y:=0;
for i:=1 to length(s) do begin
    if s[i]='L' then dec(x);
    if s[i]='R' then inc(x);
    if s[i]='U' then inc(y);
    if s[i]='D' then dec(y);
    k:=0;
    if a[x][y] then inc(k);
    if a[x-1][y] then inc(k);
    if a[x+1][y] then inc(k);
    if a[x][y-1] then inc(k);
    if a[x][y+1] then inc(k);
    if k>1 then f:=false;
    a[x][y]:=true;
end;
if f then write('OK') else write('BUG');
end.